//
//  CreateJobReviewCommertialOwnerInfoView.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/3/7.
//

import UIKit
import SnapKit
class CreateJobReviewCommertialOwnerInfoView: View {
    let propertyTypeText = CreateJobReviewContentLabel()
    let ownerTypeText = CreateJobReviewContentLabel()
    let companyAbnText = CreateJobReviewContentLabel()
    let companyNameText = CreateJobReviewContentLabel()
    let representativeNameText = CreateJobReviewContentLabel()
    let positionText = CreateJobReviewContentLabel()
    let mobileText = CreateJobReviewContentLabel()
    let emailText = CreateJobReviewContentLabel()
    let stcUnitPriceText = CreateJobReviewContentLabel()
    let gstText = ContentLabel()
    override func setUpView() {
        //property type
        let propertyTypeTitle = CreateJobReviewTitleLabel(R.string.localizable.propertyType())
        self.addSubview(propertyTypeTitle)
        propertyTypeTitle.snp.makeConstraints { make in
            make.top.equalTo(16)
            make.left.equalTo(12)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(propertyTypeText)
        propertyTypeText.snp.makeConstraints { make in
            make.top.equalTo(propertyTypeTitle)
            make.right.equalTo(-12)
            make.size.greaterThanOrEqualTo(0)
        }
        //owner type
        let ownerTypeTitle = CreateJobReviewTitleLabel(R.string.localizable.ownerType())
        self.addSubview(ownerTypeTitle)
        ownerTypeTitle.snp.makeConstraints { make in
            make.top.equalTo(propertyTypeTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(ownerTypeText)
        ownerTypeText.snp.makeConstraints { make in
            make.top.equalTo(ownerTypeTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //company abn
        let companyAbnTitle = CreateJobReviewTitleLabel(R.string.localizable.companyABN())
        self.addSubview(companyAbnTitle)
        companyAbnTitle.snp.makeConstraints { make in
            make.top.equalTo(ownerTypeTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(companyAbnText)
        companyAbnText.snp.makeConstraints { make in
            make.top.equalTo(companyAbnTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //companyName
        let companyNameTitle = CreateJobReviewTitleLabel(R.string.localizable.companyName())
        self.addSubview(companyNameTitle)
        companyNameTitle.snp.makeConstraints { make in
            make.top.equalTo(companyAbnTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        companyNameText.numberOfLines = 0
        companyNameText.textAlignment = .right
        self.addSubview(companyNameText)
        companyNameText.snp.makeConstraints { make in
            make.top.equalTo(companyNameTitle)
            make.left.equalTo(companyNameTitle.snp.right).offset(5)
            make.right.equalTo(propertyTypeText)
            make.height.greaterThanOrEqualTo(companyNameTitle)
            
        }
        //representativeName
        let representativeNameTitle = CreateJobReviewTitleLabel(R.string.localizable.companyRepresentativeFullName())
        self.addSubview(representativeNameTitle)
        representativeNameTitle.snp.makeConstraints { make in
            make.top.equalTo(companyNameText.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(representativeNameText)
        representativeNameText.snp.makeConstraints { make in
            make.top.equalTo(representativeNameTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //position
        let positionTitle = CreateJobReviewTitleLabel(R.string.localizable.position())
        self.addSubview(positionTitle)
        positionTitle.snp.makeConstraints { make in
            make.top.equalTo(representativeNameTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(positionText)
        positionText.snp.makeConstraints { make in
            make.top.equalTo(positionTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //mobie
        let mobieTitle = CreateJobReviewTitleLabel(R.string.localizable.mobile())
        self.addSubview(mobieTitle)
        mobieTitle.snp.makeConstraints { make in
            make.top.equalTo(positionTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(mobileText)
        mobileText.snp.makeConstraints { make in
            make.top.equalTo(mobieTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //email
        let emailTitle = CreateJobReviewTitleLabel(R.string.localizable.mobile())
        self.addSubview(emailTitle)
        emailTitle.snp.makeConstraints { make in
            make.top.equalTo(mobieTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(emailText)
        emailText.snp.makeConstraints { make in
            make.top.equalTo(emailTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        
        //stc unit price
        let stcUnitPriceTitle = CreateJobReviewTitleLabel(R.string.localizable.ownerSSTCUnitPrice())
        self.addSubview(stcUnitPriceTitle)
        stcUnitPriceTitle.snp.makeConstraints { make in
            make.top.equalTo(emailTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
        }
        self.addSubview(stcUnitPriceText)
        stcUnitPriceText.snp.makeConstraints { make in
            make.top.equalTo(stcUnitPriceTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
        //gst
        let gstTitle = CreateJobReviewTitleLabel(R.string.localizable.gsT())
        self.addSubview(gstTitle)
        gstTitle.snp.makeConstraints { make in
            make.top.equalTo(stcUnitPriceTitle.snp.bottom).offset(CREATEJOB_REVIEW_INTERNAL)
            make.left.equalTo(propertyTypeTitle)
            make.size.greaterThanOrEqualTo(0)
            make.bottom.equalTo(-16)
        }
        self.addSubview(gstText)
        gstText.snp.makeConstraints { make in
            make.top.equalTo(gstTitle)
            make.right.equalTo(propertyTypeText)
            make.size.greaterThanOrEqualTo(0)
        }
    }
    
    func setData(){
        self.propertyTypeText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.property_type.rawValue
        self.ownerTypeText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.owner_type.rawValue
        self.companyAbnText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.home_owner_abn
        self.companyNameText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.company_name
        self.representativeNameText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.owner_representative_name
        self.positionText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.owner_representative_position
        self.mobileText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.mobile
        self.emailText.text = CreateJobModelHelper.shared.createJobViewModel.propertyOwner.email
        self.stcUnitPriceText.text = "$" + CreateJobModelHelper.shared.createJobViewModel.propertyOwner.price_to_the_home_owner
        self.gstText.text = (CreateJobModelHelper.shared.createJobViewModel.propertyOwner.gst ? "Yes" : "No")
    }
}
